#ifndef __H65_CMOS_PARAM_H_
#define __H65_CMOS_PARAM_H_

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

#include <linux/cvi_vip_cif.h>
#include <linux/cvi_vip_snsr.h>
#include "cvi_type.h"
#include "cvi_sns_ctrl.h"
#include "h65_cmos_ex.h"

static const H65_MODE_S g_astH65_mode[H65_MODE_NUM] = {
	[H65_MODE_720P30] = {
		.name = "720p30",
		.astImg[0] = {
			.stSnsSize = {
				.u32Width = 1280,
				.u32Height = 720,
			},
			.stWndRect = {
				.s32X = 0,
				.s32Y = 0,
				.u32Width = 1280,
				.u32Height = 720,
			},
			.stMaxSize = {
				.u32Width = 1280,
				.u32Height = 720,
			},
		},
		.f32MaxFps = 30,
		.f32MinFps = 0.92, /* 0x3e8 * 30 / 0x7FFF */
		.u32HtsDef = 0x2d0,
		.u32VtsDef = 0x3e8,
		.stExp[0] = {
			.u16Min = 1,
			.u16Max = 1120,
			.u16Def = 400,
			.u16Step = 1,
		},
		.stAgain[0] = {
			.u16Min = 1024,
			.u16Max = 15872,
			.u16Def = 1024,
			.u16Step = 1,
		},
		.stDgain[0] = {
			.u16Min = 1024,
			.u16Max = 4096,
			.u16Def = 1024,
			.u16Step = 1,
		},
		.u8DgainReg = 0xF0,
	},
	[H65_MODE_720P30_WDR] = {
		.name = "720p30wdr",
		.astImg[0] = {
			.stSnsSize = {
				.u32Width = 1280,
				.u32Height = 720,
			},
			.stWndRect = {
				.s32X = 0,
				.s32Y = 0,
				.u32Width = 1280,
				.u32Height = 720,
			},
			.stMaxSize = {
				.u32Width = 1280,
				.u32Height = 720,
			},
		},
		.astImg[1] = {
			.stSnsSize = {
				.u32Width = 1280,
				.u32Height = 720,
			},
			.stWndRect = {
				.s32X = 0,
				.s32Y = 0,
				.u32Width = 1280,
				.u32Height = 720,
			},
			.stMaxSize = {
				.u32Width = 1280,
				.u32Height = 720,
			},
		},
		.f32MaxFps = 30,
		.f32MinFps = 2.06, /* 2250 * 30 / 0x7FFF */
		.u32HtsDef = 640,
		.u32VtsDef = 2250,
		.stExp[0] = {
			.u16Min = 1,
			.u16Max = 131,
			.u16Def = 13,
			.u16Step = 2,
		},
		.stExp[1] = {
			.u16Min = 132,
			.u16Max = 2096,
			.u16Def = 828,
			.u16Step = 1,
		},
		.stAgain[0] = {
			.u16Min = 1024,
			.u16Max = 1024,
			.u16Def = 1024,
			.u16Step = 1,
		},
		.stAgain[1] = {
			.u16Min = 1024,
			.u16Max = 15872,
			.u16Def = 1024,
			.u16Step = 1,
		},
		.stDgain[0] = {
			.u16Min = 1024,
			.u16Max = 1024,
			.u16Def = 1024,
			.u16Step = 1,
		},
		.stDgain[1] = {
			.u16Min = 1024,
			.u16Max = 4096,
			.u16Def = 1024,
			.u16Step = 1,
		},
		.u8DgainReg = 0xF0,
		.u32L2S_MAX = 0x2C,
	},
};

ISP_CMOS_NOISE_CALIBRATION_S g_stIspNoiseCalibration_h65 = {.CalibrationCoef = {
{	//iso  100
		{0.05442929640412330627,	4.65858936309814453125}, //B: slope, intercept
		{0.05003556609153747559,	4.79239034652709960938}, //Gb: slope, intercept
		{0.05048608407378196716,	4.68758821487426757813}, //Gr: slope, intercept
		{0.03608174994587898254,	5.41338014602661132813}, //R: slope, intercept
	},
	{	//iso  200
		{0.06345061957836151123,	6.23534488677978515625}, //B: slope, intercept
		{0.05860397964715957642,	6.82649660110473632813}, //Gb: slope, intercept
		{0.05599149689078330994,	6.81171846389770507813}, //Gr: slope, intercept
		{0.06996029615402221680,	6.11073207855224609375}, //R: slope, intercept
	},
	{	//iso  400
		{0.07858145236968994141,	8.73616504669189453125}, //B: slope, intercept
		{0.06223644316196441650,	10.41201114654541015625}, //Gb: slope, intercept
		{0.06257106363773345947,	10.21477794647216796875}, //Gr: slope, intercept
		{0.07893631607294082642,	8.40810585021972656250}, //R: slope, intercept
	},
	{	//iso  800
		{0.06475125998258590698,	20.12986755371093750000}, //B: slope, intercept
		{0.05051935836672782898,	23.07766342163085937500}, //Gb: slope, intercept
		{0.05301429703831672668,	22.21849441528320312500}, //Gr: slope, intercept
		{0.07655816525220870972,	16.55694580078125000000}, //R: slope, intercept
	},
	{	//iso  1600
		{0.05891514569520950317,	40.35498046875000000000}, //B: slope, intercept
		{0.04930473119020462036,	44.30628585815429687500}, //Gb: slope, intercept
		{0.04907533898949623108,	45.33455276489257812500}, //Gr: slope, intercept
		{0.07040018588304519653,	33.58419036865234375000}, //R: slope, intercept
	},
	{	//iso  3200
		{0.05696938931941986084,	82.33475494384765625000}, //B: slope, intercept
		{0.05457751452922821045,	82.88809204101562500000}, //Gb: slope, intercept
		{0.05322522670030593872,	85.52174377441406250000}, //Gr: slope, intercept
		{0.06931725889444351196,	67.86410522460937500000}, //R: slope, intercept
	},
	{	//iso  6400
		{0.05134947597980499268,	163.26597595214843750000}, //B: slope, intercept
		{0.01524530723690986633,	215.35070800781250000000}, //Gb: slope, intercept
		{0.01440975163131952286,	217.05438232421875000000}, //Gr: slope, intercept
		{0.07146671414375305176,	123.11108398437500000000}, //R: slope, intercept
	},
	{	//iso  12800
		{0.05676792934536933899,	156.21517944335937500000}, //B: slope, intercept
		{0.03904885053634643555,	178.52795410156250000000}, //Gb: slope, intercept
		{0.03914189338684082031,	179.96458435058593750000}, //Gr: slope, intercept
		{0.07794195413589477539,	117.93878173828125000000}, //R: slope, intercept
	},
	{	//iso  25600
		{0.05730582028627395630,	157.19354248046875000000}, //B: slope, intercept
		{0.02251610904932022095,	204.92749023437500000000}, //Gb: slope, intercept
		{0.02263967692852020264,	205.15576171875000000000}, //Gr: slope, intercept
		{0.07630427926778793335,	120.62886810302734375000}, //R: slope, intercept
	},
	{	//iso  51200
		{0.05774896219372749329,	155.40005493164062500000}, //B: slope, intercept
		{0.03742361441254615784,	181.40126037597656250000}, //Gb: slope, intercept
		{0.03751779347658157349,	182.84436035156250000000}, //Gr: slope, intercept
		{0.07821505516767501831,	117.60336303710937500000}, //R: slope, intercept
	},
	{	//iso  102400
		{0.05769459903240203857,	155.34001159667968750000}, //B: slope, intercept
		{0.03954466059803962708,	178.05091857910156250000}, //Gb: slope, intercept
		{0.03932188823819160461,	179.61857604980468750000}, //Gr: slope, intercept
		{0.07880732417106628418,	117.00097656250000000000}, //R: slope, intercept
	},
	{	//iso  204800
		{0.05828985199332237244,	154.35301208496093750000}, //B: slope, intercept
		{0.04372645914554595947,	171.65762329101562500000}, //Gb: slope, intercept
		{0.04317585006356239319,	173.56425476074218750000}, //Gr: slope, intercept
		{0.07923986762762069702,	116.26798248291015625000}, //R: slope, intercept
	},
	{	//iso  409600
		{0.05909869074821472168,	151.79585266113281250000}, //B: slope, intercept
		{0.04804354906082153320,	165.54621887207031250000}, //Gb: slope, intercept
		{0.04891717061400413513,	165.20520019531250000000}, //Gr: slope, intercept
		{0.08096204698085784912,	113.96572113037109375000}, //R: slope, intercept
	},
	{	//iso  819200
		{0.05871304869651794434,	152.44145202636718750000}, //B: slope, intercept
		{0.05063246563076972961,	161.40238952636718750000}, //Gb: slope, intercept
		{0.05038788542151451111,	163.13931274414062500000}, //Gr: slope, intercept
		{0.08144226670265197754,	113.47839355468750000000}, //R: slope, intercept
	},
	{	//iso  1638400
		{0.05942720174789428711,	151.25903320312500000000}, //B: slope, intercept
		{0.05093461275100708008,	160.45484924316406250000}, //Gb: slope, intercept
		{0.05029597133398056030,	163.43736267089843750000}, //Gr: slope, intercept
		{0.08148754388093948364,	113.46115112304687500000}, //R: slope, intercept
	},
	{	//iso  3276800
		{0.05719726532697677612,	156.28390502929687500000}, //B: slope, intercept
		{0.03733940050005912781,	182.15731811523437500000}, //Gb: slope, intercept
		{0.03721711039543151855,	183.17344665527343750000}, //Gr: slope, intercept
		{0.07687065005302429199,	118.86908721923828125000}, //R: slope, intercept
	},
} };

static ISP_CMOS_BLACK_LEVEL_S g_stIspBlcCalibratio = {
	.bUpdate = CVI_TRUE,
	.blcAttr = {
		.Enable = 1,
		.enOpType = OP_TYPE_AUTO,
		.stManual = {68, 68, 68, 68, 1096, 1096, 1096, 1096},
		.stAuto = {
			{65, 68, 66, 69, 69, 73, 83, 83, 83, 83, 83, 83, 83, 83, 83, 82},
			{65, 68, 66, 69, 69, 74, 84, 84, 84, 84, 84, 84, 84, 84, 84, 83},
			{65, 67, 65, 68, 66, 71, 79, 79, 79, 79, 79, 78, 79, 79, 78, 79},
			{65, 67, 65, 68, 66, 71, 80, 80, 80, 80, 80, 79, 80, 80, 79, 79},
		       {1041, 1041, 1041, 1042, 1042, 1043, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045},
		       {1041, 1041, 1041, 1042, 1042, 1043, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045},
		       {1041, 1041, 1041, 1041, 1041, 1042, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044},
		       {1041, 1041, 1041, 1041, 1041, 1042, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044},
		},
	},
};

struct combo_dev_attr_s h65_rx_attr = {
	.input_mode = INPUT_MODE_MIPI,
	.mac_clk = RX_MAC_CLK_200M,
	.mipi_attr = {
		.raw_data_type = RAW_DATA_10BIT,
		.lane_id = {2, 0, 1, 3, 4},
		.wdr_mode = CVI_MIPI_WDR_MODE_MANUAL,
		.dphy = {
			.enable = 1,
			.hs_settle = 8,
		},
	},
	.mclk = {
		.cam = 0,
		.freq = CAMPLL_FREQ_25M,
	},
	.devno = 0,
};

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */


#endif /* __H65_CMOS_PARAM_H_ */
